package com.ctshk.rpc.goods.mapper.provider;

import org.apache.ibatis.jdbc.SQL;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ctshk.rpc.goods.dto.FreightTemplateDTO;
import com.ctshk.rpc.goods.req.FreightTemplatePageReq;

/**
 * 运费模板-分页列表查询
 * @author 姜斌文
 * @since 2021-04-09
 */
public class FreightTemplateProvider {
	
    public String findFreightTemplateByAll(IPage<FreightTemplateDTO> page,FreightTemplatePageReq pageReq) {
    	String sql = new SQL() {{
                SELECT("t.id, t.template_name, t.pricing_method, t.is_free_shipping, t.cash_on_delivery, t.gmt_create, t.sort");
                FROM("`ctshk-goods`.t_freight_template t");
                WHERE("t.is_deleted = 0");
                if(pageReq.getUserIds() != null){
                    WHERE("t.create_id in (${pageReq.userIds})");
                }
                ORDER_BY("t.sort ASC, t.gmt_create DESC");
            }}.toString();
            return sql;
    }
}
